package com.kk.miaosha.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kk.miaosha.entity.ItemKillSuccess;
import com.kk.miaosha.exception.R;
import com.kk.miaosha.service.ItemKillSuccessService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : K k
 * @date : 10:25 2020/10/27
 */
@RestController
@RequestMapping("order")
@Slf4j
@Api(value = "OrderController",description = "支付业务接口")
public class OrderController {

    @Autowired
    private ItemKillSuccessService iksService;

    @GetMapping("/getOrders/{userId}")
    public R getOrders(@PathVariable("userId")Integer userId){
        List<ItemKillSuccess> orders = iksService.list(new QueryWrapper<ItemKillSuccess>().eq("user_id",userId));
        if (orders==null || orders.size()==0){
            return R.error("无订单信息");
        }else{
            return R.ok().data("orders",orders);
        }
    }
}
